import { Popconfirm } from "antd"
import styles from './index.module.less'

const getColumns = (/* onOpen, onDelete */) => [
  {
    id: 0,
    dataIndex: 'name',
    title: '调度名称',
    width: 300
  },
  {
    id: 1,
    dataIndex: 'scheduler_type',
    title: '调度类型'
  },
  {
    id: 2,
    dataIndex: 'type',
    title: '调度方式'
  },
  {
    id: 3,
    dataIndex: 'playbook_ids',
    title: '调度剧本'
  },
  {
    id: 4,
    dataIndex: 'status',
    title: '调度状态'
  },
  {
    id: 5,
    dataIndex: 'created_by',
    title: '创建人'
  },
  {
    id: 6,
    dataIndex: 'created_at',
    title: '创建时间'
  },
  {
    id: 7,
    dataIndex: 'start_time',
    title: '调度开始时间'
  },
  {
    id: 8,
    dataIndex: 'end_time',
    title: '调度结束时间'
  }
]

const getOperationItemConfig = (onOpen, onDelete) => record => {
  return [
    {
      title: '结束',
      click: () => {
        onOpen('control')
      }
    },
    {
      title: '查看',
      click: () => {
        onOpen('check', record)
      }
    },
    {
      title: '编辑',
      click: () => {
        onOpen('update', record)
      }
    },
    {
      title: '复制',
      click: () => {
        onOpen('copy', record)
      }
    },
    {
      title: '删除',
      render: () => {
        return (
          <Popconfirm
            title="您确定要删除吗?"
            onConfirm={() => onDelete({ ids: [record.id] })}
            okText="确定"
            cancelText="取消"
          >
            <span className={styles['operation_btn']}>删除</span>
          </Popconfirm>
        )
      }
    }
  ]
}
export { getColumns, getOperationItemConfig }
